#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
    char username[26][4];//一定要初始化,否则会塞一些乱七糟八的东西
    int n=0;
    char ip1[7]= "\0\0\0\0\0\0";
    char ip2[7]= "\0\0\0\0\0\0";
    char input[7]="\0\0\0\0\0\0";
    for(int i=0;i<26;i++){
        username[i][1]='\0';
    }
    for(char i='A';i<='Z';i++){//可以直接运算
           username[n][0]=i;
           n++;
    }
    
    FILE *file;
    file=fopen("level1-1.txt","r");
    fgets(input,sizeof(input),file);
    input[5]='\0';
    fgets(ip1,sizeof(ip1),file);
    fclose(file);

    int exe=0;
    while(exe==0){
        if(strcmp(input,"Login")==0){
            for(int line=0;line<26;line++){
                if(strcmp(ip1,username[line])==0){
                    printf("login successful\n");
                    int jm1=0;
                    while(jm1==0){
                        printf("please enter too:   ");
                        scanf("%s",&ip2);
                        if(strcmp(ip2,"Quit")==0){

                            FILE *file;
                            file=fopen("level1-1.txt","w");
                            input[5]='\n';
                            fputs(input,file);
                            fputs(ip1,file);
                            fclose(file);

                            exit(0);
                        }
                        if(strcmp(ip2,"Exit")==0){
                            jm1=1;
                            ip1[0]='\0';
                            for(int i=0;i<5;i++){
                                input[0]='\0';
                            }
                            
                            FILE *file;
                            file=fopen("level1-1.txt","w");
                            fputs(input,file);
                            fputs(ip1,file);
                            fclose(file);

                        }
                    }
                }
            }
        }

        printf("please enter:  ");
        scanf("%s",&input);
        while(strcmp(input,"Login")==0){
            int line=0;
            printf("please enter your username: ");
            scanf("%s",&ip1);
            for(line=0;line<26;line++){
                if(strcmp(ip1,username[line])==0){
                    printf("login successful\n");
                    int jm1=0;
                    while(jm1==0){
                        printf("please enter too:   ");
                        scanf("%s",&ip2);
                        if(strcmp(ip2,"Quit")==0){

                            FILE *file;
                            file=fopen("level1-1.txt","w");
                            input[5]='\n';
                            fputs(input,file);
                            fputs(ip1,file);
                            fclose;

                            exit(0);
                        }
                        if(strcmp(ip2,"Exit")==0){
                            jm1=1;
                            line=26;
                            ip1[0]=0;
                            for(int i=0;i<5;i++){
                                input[0]='\0';
                            }

                            FILE *file;
                            file=fopen("level1-1.txt","w");
                            fputs(input,file);
                            fputs(ip1,file);
                            fclose(file);
                            break;

                        }
                    }
                }
                else if(strcmp(ip1,"Quit")==0){

                    exit(0);
                }
            }
            if(line==26){
                printf("username doesn't exit\n"); 
            }   
        }
        if(strcmp(input,"Quit")==0){
            exit(0);
        }
    }
    return 0;
}